home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 February: Technology Seed / Mac Tech Seed Feb '97.toast / ODF Release 3 / ODFDev / Draw / Sources / DrawLink.h < prev    next >
Encoding:
Text File  |  1996-12-16  |  7.1 KB  |  226 lines  |  [TEXT/MPS ]

  1. //========================================================================================
  2. //
  3. //    File:                DrawLink.h
  4. //    Release Version:    $ ODF 3 $
  5. //
  6. //    Author:                Henri Lamiraux
  7. //
  8. //    Copyright:    (c) 1993 - 1996 by Apple Computer, Inc., all rights reserved.
  9. //
  10. //========================================================================================
  11.  
  12. #ifndef DRAWLINK_H
  13. #define DRAWLINK_H
  14.  
  15. // ----- Part Layer -----
  16.  
  17. #ifndef FWLNKDST_H
  18. #include "FWLnkDst.h"
  19. #endif
  20.  
  21. #ifndef FWLNKSRC_H
  22. #include "FWLnkSrc.h"
  23. #endif
  24.  
  25. #ifndef FWLNKMGR_H
  26. #include "FWLnkMgr.h"
  27. #endif
  28.  
  29. #ifndef FWPOINT_H
  30. #include "FWPoint.h"
  31. #endif
  32.  
  33. //========================================================================================
  34. //    Forward Declarations
  35. //========================================================================================
  36.  
  37. class FW_CFrame;
  38. class FW_CCloneInfo;
  39.  
  40. class CBaseShape;
  41. class CDrawSelection;
  42. class CDrawPart;
  43. class CDrawContent;
  44. class CDrawLinkContent;
  45. class CDrawLinkSourceContent;
  46. class CGroupShape;
  47.  
  48. //========================================================================================
  49. //    class CDrawPublishLink
  50. //========================================================================================
  51.  
  52. class CDrawPublishLink : public FW_CLinkSource
  53. {
  54.   public:
  55.     CDrawPublishLink(Environment* ev, 
  56.                     ODUpdateID updateID, 
  57.                     FW_CPresentation* presentation,
  58.                     CDrawSelection* drawSelection,
  59.                     FW_Boolean saveSelection);
  60.     virtual ~ CDrawPublishLink();
  61.     
  62.     //--- FW_CLinkSource overrides
  63.     virtual void        LinkEstablished(Environment* ev);
  64.     virtual void        ExternalizeLinkContent(Environment* ev, ODStorageUnit* linkSU);
  65.     
  66.     virtual void        DoExternalizeLink(Environment* ev, ODStorageUnit* storageUnit,
  67.                                           FW_CCloneInfo* cloneInfo);
  68.  
  69.     virtual FW_Boolean    HasEmbeddedFrame(Environment* ev, ODFrame* odEmbeddedFrame);
  70.  
  71.     virtual void        RevealLinkSource(Environment* ev, FW_CFrame* frame);
  72.  
  73.     virtual void        BreakLink(Environment* ev);
  74.     virtual void        RestoreLink(Environment* ev, FW_CPart* part);
  75.  
  76.     //--- Part-specific
  77.     void                AddShape(Environment* ev, CBaseShape* shape);
  78.     FW_Boolean            IsEmpty();
  79.     void                RemoveShape(Environment* ev, CBaseShape* shape);
  80.     virtual FW_Boolean IsOKtoUpdate(Environment* ev, FW_Boolean forceUpdate = FALSE);
  81.     unsigned long Count();
  82.  
  83.  
  84.  
  85.   private:
  86.     CDrawSelection*            fDrawSelection;
  87.     CDrawLinkSourceContent*    fPublishedContent;
  88. };
  89.  
  90. //========================================================================================
  91. // Typedef
  92. //========================================================================================
  93.  
  94. typedef FW_TOrderedCollection<CDrawPublishLink> CDrawPublishLinkCollection;
  95. typedef FW_TOrderedCollectionIterator<CDrawPublishLink> CDrawPublishLinkCollectionIterator;
  96.  
  97. //========================================================================================
  98. //    class CDrawSubscribeLink
  99. //========================================================================================
  100.  
  101. class CDrawSubscribeLink : public FW_CLinkDestination
  102. {
  103.     friend class CDrawLinkManager;
  104.  
  105.   public:
  106.     CDrawSubscribeLink(Environment* ev, ODLink* odLink,
  107.                         FW_CPresentation* presentation, 
  108.                         CDrawSelection* drawSelection,
  109.                         ODLinkInfo* linkInfo,
  110.                         FW_Boolean createGroupShape=true);
  111.     virtual ~ CDrawSubscribeLink();
  112.  
  113.     //--- FW_CLinkDestination Overrides ---
  114.     virtual FW_Boolean    DoUpdateLink(Environment* ev, ODStorageUnit* linkContentSU, ODPasteAsResult* embedAsInfo);
  115.     virtual void        BreakLink(Environment* ev);
  116.     virtual void        LinkEstablished(Environment* ev);
  117.  
  118.     virtual void        DoExternalizeLink(Environment* ev, ODStorageUnit* storageUnit,
  119.                                       FW_CCloneInfo* cloneInfo);
  120.  
  121.     virtual FW_CFrame*    GetContainingFrame(Environment* ev, ODFrame* odEmbeddedFrame);
  122.  
  123.     //--- Draw part-specific ---
  124.   public:
  125.     
  126.     void SelectShapes(Environment* ev);
  127.  
  128.     void AdjustUpdateOffset(Environment* ev, const FW_CPoint& delta);
  129.     void SetUpdateOffset(Environment* ev, const FW_CPoint& offset);
  130.     
  131.   private:
  132.     void UpdateLinkedContent(Environment* ev);
  133.     
  134.     void AddShape(Environment* ev, CBaseShape* shape);
  135.     void SetGroupShape(Environment* ev, CGroupShape* shape);
  136.  
  137.   private:
  138.     CDrawPart*                        fDrawPart;
  139.     CDrawSelection*                    fDrawSelection;
  140.     CDrawLinkContent*                fLinkedContent;
  141.     CGroupShape*                    fGroupShape;
  142.     FW_CPoint                        fUpdateOffset;
  143.     FW_Boolean                        fFirstUpdate;
  144.     FW_Boolean                        fFirstOffset;
  145.     FW_Boolean                        fCalcGroupOffset;
  146. };
  147.  
  148. //----------------------------------------------------------------------------------------
  149. inline void CDrawSubscribeLink::SetUpdateOffset(Environment*, const FW_CPoint& offset)
  150. {
  151.     fUpdateOffset = offset;
  152.     fCalcGroupOffset = false;
  153. }
  154.  
  155. //========================================================================================
  156. // Typedef
  157. //========================================================================================
  158.  
  159. typedef FW_TOrderedCollection<CDrawSubscribeLink> CDrawSubscribeLinkCollection;
  160. typedef FW_TOrderedCollectionIterator<CDrawSubscribeLink> CDrawSubscribeLinkCollectionIterator;
  161.  
  162. //========================================================================================
  163. //    class CDrawLinkManager
  164. //========================================================================================
  165.  
  166. class CDrawLinkManager : public FW_CLinkManagerImplementation
  167. {
  168. //----------------------------------------------------------------------------------------
  169. //    Constructors/Destructors
  170. //
  171.   public:
  172.     FW_DECLARE_AUTO(CDrawLinkManager)
  173.  
  174.     CDrawLinkManager(Environment* ev, CDrawPart* thePart);
  175.     virtual ~CDrawLinkManager();
  176.  
  177. //----------------------------------------------------------------------------------------
  178. //    Override Methods
  179. //
  180.   public:
  181.     virtual FW_CLinkSource*     NewLinkSource(Environment* ev, 
  182.                                               ODUpdateID updateID, 
  183.                                               FW_CPresentation* presentation);
  184.     virtual FW_CLinkDestination* NewLinkDestination(Environment* ev, 
  185.                                                     ODLink* odLink,
  186.                                                     ODLinkInfo* linkInfo,
  187.                                                     FW_CPresentation* presentation);
  188.  
  189.     virtual void                DoChangeLinkStatus(Environment* ev, ODFrame* odFrame);
  190.                                 // formerly named LinkStatusChanged
  191.  
  192. //----------------------------------------------------------------------------------------
  193. //    Support for Persistent Links
  194. //
  195.   public:
  196.     virtual FW_CLinkSource*        DoInternalizeOneSourceLink(Environment* ev, 
  197.                                                            ODStorageUnit* storageUnit,
  198.                                                            ODUpdateID updateID);
  199.     virtual FW_CLinkDestination* DoInternalizeOneDestLink(Environment* ev, 
  200.                                                          ODStorageUnit* storageUnit,
  201.                                                          ODLink* odLink, 
  202.                                                          ODLinkInfo* linkInfo);
  203.  
  204.     virtual ODValueType            GetSourceLinkFormat(Environment* ev);
  205.     virtual ODValueType            GetDestLinkFormat(Environment* ev);
  206.  
  207.   private:
  208.     ODULong GetSUValue(Environment* ev, ODStorageUnit* su, unsigned long size, void *buffer);
  209.  
  210. //----------------------------------------------------------------------------------------
  211. //    Support for Undo/Redoing PasteAs
  212. //
  213.   public:
  214.     virtual void UndoPasteAs(Environment* ev, CDrawSubscribeLink* link);
  215.     virtual void RedoPasteAs(Environment* ev, CDrawSubscribeLink* link);
  216.  
  217.     
  218.  
  219. //----------------------------------------------------------------------------------------
  220. //    Data Members
  221. //
  222.   private:
  223.     CDrawPart*        fDrawPart;
  224. };
  225.  
  226. #endif